//
//  MLASavePinBillDetailVC.m
//  MagicLampApp
//
//  Created by Zheng on 2018/12/29.
//  Copyright © 2018 zheng.magic.lamp.app. All rights reserved.
//

#import "MLASavePinBillDetailVC.h"
#import "MLASavePinBillModel.h"

@interface MLASavePinBillDetailVC ()

@end

@implementation MLASavePinBillDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configTitle:@"凭证详情"];
    
    [self loadData];
}

#pragma mark - LoadData
- (void)loadData {
    
    NSDictionary *params = @{@"id":_modelId};
    [MLAHttpManage postHostType:MLAHttpHostType_Jinxiaocun api:kBillDetail params:params success:^(id  _Nonnull response, NSString * _Nonnull msg) {
        MLASavePinBillModel *model = [MLASavePinBillModel mj_objectWithKeyValues:response[@"lists"]];
        [self configSubviews:model];
    } failure:^{
        
    }];
}

#pragma mark - Subviews
- (void)configSubviews:(MLASavePinBillModel *)model {
    
    self.showAccessoryView = YES;
    
    self.titlesArr = @[[NSString stringWithFormat:@"类别：%@",model.type],
                       [NSString stringWithFormat:@"事项：%@",model.title],
                       [NSString stringWithFormat:@"持票人：%@",model.holder],
                       [NSString stringWithFormat:@"审核人：%@",model.check],
                       [NSString stringWithFormat:@"金额：%@",model.price]];
    
    UIView *footerView = [[UIView alloc] init];
    footerView.frame = CGRectMake(0, 0, CX_GetXScale(80), CX_GetXScale(80)*0.78+20);
    
    UILabel *titleLbl = [[UILabel alloc] init];
    titleLbl.font = CX_GetNormalFont(12);
    titleLbl.textColor = CX_GetColorTitle();
    titleLbl.frame = CGRectMake(15, 20, 40, 20);
    titleLbl.text = @"附件：";
    [footerView addSubview:titleLbl];
    
    [model.file_array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UIImageView *imgv = [[UIImageView alloc] init];
        [imgv sd_setImageWithURL:[NSURL URLWithString:obj]];
        imgv.frame = CGRectMake(55+(CX_GetXScale(80)+15)*idx, 20, CX_GetXScale(80), CX_GetXScale(80)*0.78);
        imgv.layer.cornerRadius = CX_GetXScale(5);
        imgv.layer.masksToBounds = YES;
        [footerView addSubview:imgv];
    }];
    
    self.tableView.tableFooterView = footerView;
    
    [self.tableView reloadData];

}




@end
